<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<p>
		整数1：<input type="text" id="old">
	</p>
	<p>
		整数2：<input type="text" id="old1">
	</p>
	<p>
		<button onclick="up('+')">相加</button>
		<button onclick="up('-')">相减</button>
		<button onclick="up('*')">相乘</button>
		<button onclick="up('/')">相除</button>
		<!-- <button onclick="up(1)">相加</button>
		<button onclick="up(2)">相减</button>
		<button onclick="up(3)">相乘</button>
		<button onclick="up(4)">相除</button> -->
	</p>
	<p>
		结果：<input type="text" id="new">
	</p>


	<script>
		function up(a){
			var text = document.querySelector("#old").value;
			var text1 = document.querySelector("#old1").value;
			text  = Number(text);
			text1 = Number(text1);
			var all = 0;
			switch (a){
				case"+":all = text + text1;break;
				case"-":all = text - text1;break;
				case"*":all = text * text1;break;
				case"/":all = text / text1;break;
			}
			document.querySelector("#new").value = all;
		}
		


		// function up(c){
		// 	var text = document.querySelector("#old").value;
		// 	var text1 = document.querySelector("#old1").value;
		// 	var text3 = document.querySelector("#new");
		// 	text = Number(text);
		// 	text1 = Number(text1);
		// 	if(c == 1){
		// 		text3.value = text + text1;
		// 	}
		// 	if(c == 2){
		// 		text3.value = text - text1;
		// 	}
		// 	if(c == 3){
		// 		text3.value = text * text1;
		// 	}
		// 	if(c == 4){
		// 		text3.value = text / text1;
		// 	}
		// }




	</script>
</body>
</html>